<template>
  <div>
    <Phead />
    <Pmsg />
      <div class="personal-content w clearfix">
         <Pmy />

          <!-- 成为合伙人 -->
            <!-- 个人中心 > 成为合伙人 -->
        <div class="right myorder">
            <!-- 个人中心tab切换栏 -->
            <h3 class="stamp">我的订单</h3>
            <div class="numbox">
                <h5>邀请医院数：<span>{{hospitalNum}}家</span></h5>
                <h5>成交单数：<span>{{dealNum}}单</span></h5>
                <button>已认证</button>
            </div>


            <!-- 成为合伙人 -->
            <div class="partner">
                <table class="clearfix">
                    <thead>
                        <th>我邀请的医院</th>
                    </thead>
                    <tbody>
                        <tr v-for="(item,index) in hospital" :key="index">
                            <td>{{item.company_name}}</td>
                            <td>日期：{{item.add_time}}</td>
                        </tr>
                        
                    </tbody>
                </table>
                <div class="yaoqingma">
                    <div class="cccbox">
                        <span>邀请码&nbsp;&nbsp;&nbsp;</span><input type="text" id="content" :value="inviteCode"></i>
                    </div>
                    <div class="greenbox" id="copy" @click="toCopy">
                        点击复制
                    </div>
                </div>
            </div>
        </div>


     </div>
    <Pfoot />
      <!-- 表单验证 -->
      <Pdailog :is-show="formAlertShow" @on-close="formAlertClose" >
           <div slot="main">{{formAlertText}}</div>
      </Pdailog>

  </div>


</template>

<script>
import Phead from '@/components/Phead.vue'
import Pfoot from '@/components/Pfoot.vue'
import Pmy from '@/components/Pmy.vue'
import Pmsg from '@/components/Pmsg.vue'
import Pdailog from '@/components/Pdailog.vue'

export default {
  data(){
    return{
        hospitalNum:0, //邀请医院数
        dealNum:0, //邀请医院 成交数
        hospital:[],//邀请的医院
        inviteCode: '',   //邀请码

        //form 错误提示
        formAlertShow:false,
        formAlertText:'提示',
          
     }
  },
  async created(){
    let user_token = this.getUserToken()
    let re = await this.$axios.post('user/getInviteInfo',{
        user_token:user_token
    })
    if(re.code == 200){
          this.hospitalNum = re.data.hospital_num
          this.dealNum = re.data.deal_num
          this.hospital = re.data.hospital

          this.inviteCode = re.data.invite_code
         
      }      
  },
  
  mounted(){
            
  },
  
  components: {
    Phead,
    Pfoot,
    Pmy,
    Pmsg,
    Pdailog

  },

  methods:{
    toCopy(){
        let that =this;
        this.$copyText(this.inviteCode).then(function (e) {
            
          that.formAlertShow =true
          that.formAlertText =`复制成功`

        }, function (e) {
          console.log(e)
        })
      },
      //表单错误提示弹框
    formAlertClose(){
        this.formAlertShow = false;
    }, 

  }

}

</script>